package com.wd.tech.activity.base;

import java.lang.ref.WeakReference;

/**
 * @author 时文豪
 * @description:
 * @date :2020/7/2 11:56
 */
public abstract class BasePreantert<V extends IBaseView> {

    private WeakReference<V> vWeakReference;

    public BasePreantert(V v) {
        vWeakReference = new WeakReference<>(v);
        initModel();
    }

    public V getView() {
        if (vWeakReference != null) {
            return vWeakReference.get();
        }
        return null;
    }

    protected abstract void initModel();

    protected void datachView() {
        if (vWeakReference != null) {
            vWeakReference.clear();
            vWeakReference = null;
        }

    }

}
